﻿using Newtonsoft.Json.Linq;

namespace PlurkApi
{
    /// <summary>
    /// a rough information of your plurk messages
    /// </summary>
    public class unreadCount
    {
        /// <summary>
        /// all the number of plurk messages 
        /// </summary>
        public int all { get; set; }

        /// <summary>
        /// the number of my posted plurk messages 
        /// </summary>
        public int my { get; set; }

        /// <summary>
        /// the number of my private plurk messages 
        /// </summary>        
        public int @private { get; set; }

        /// <summary>
        /// the number of my responded plurk messages 
        /// </summary>  
        public int responded { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="unreadCount"/> class.
        /// </summary>
        /// <param name="jsonString">The json string.</param>
        public unreadCount(string jsonString)
        {
            var obj = JObject.Parse(jsonString);
            if (obj.Count <= 0) { return; }

            all = (obj["all"] == null) ? 0 : (int)obj["all"];
            my = (obj["my"] == null) ? 0 : (int)obj["my"];
            @private = (obj["private"] == null) ? 0 : (int)obj["private"];
            responded = (obj["responded"] == null) ? 0 : (int)obj["responded"];
        }
    }
}
